package org.cli.admin.glassfish.commands;

import static org.fusesource.jansi.Ansi.ansi;
import static org.fusesource.jansi.Ansi.Color.RED;

import org.cli.admin.command.AbstractCommand;
import org.cli.admin.command.Command;
import org.cli.admin.command.CommandModule;
import org.cli.admin.glassfish.context.DeployTarget;
import org.cli.admin.glassfish.context.GlassfishContext;
import org.fusesource.jansi.Ansi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.beust.jcommander.Parameter;
import com.google.inject.Inject;

@Command(name = "glassfish-deploy", aliases = { "gdeploy", "gd" }, global = true)
public class GlassfishDeployCommand extends AbstractCommand {

	private static final Logger logger = LoggerFactory.getLogger(GlassfishDeployCommand.class);

	@Parameter(names = { "-i", "-domain" }, description = "Glassfish installation name")
	public String installationName;

	@Parameter(names = { "-t", "-target" }, description = "Deployment target")
	public String targetName;

	@Inject
	private GlassfishContext context;

	@Override
	public void execute() {
		DeployTarget target = context.getTarget(targetName);

		if (null == target)
		{
			logger.error("Null target passed");
			System.out.println(ansi().a(Ansi.Attribute.INTENSITY_BOLD).fg(RED).a("Could not found command ").
	                fg(Ansi.Color.RED).a("target").fg(RED).newline().reset().a("please use glassfish-new command"));
			return;
		}
	}

}
